﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LoungeRepo.Core;

namespace Queries
{
    class NonEntityPerson
    {
        public string Name;
        public string City;
    }


    class Program
    {
        static void Main(string[] args)
        {
            using(var repo = new LoungeRepository())
            {
                repo.Store(new NonEntityPerson{Name="Peter", City="Seattle"}, "1");
                repo.Store(new NonEntityPerson { Name = "Paul", City = "Paris" }, "2");
                repo.Store(new NonEntityPerson { Name = "Mary", City = "Hamburg" }, "3");
                repo.Store(new NonEntityPerson { Name = "Bob", City = "Seattle" }, "4");
                repo.Store(new NonEntityPerson { Name = "Martin", City = "New York" }, "5");

                Console.WriteLine("---In Seattle");
                Dump(repo.GetExtent<NonEntityPerson>().Where(p => p.City == "Seattle"));
                Console.WriteLine("---Name=M*");
                Dump(repo.GetExtent<NonEntityPerson>().Where(p => p.Name.StartsWith("M")));
            }
        }


        static void Dump(IEnumerable<NonEntityPerson> persons)
        {
            foreach (NonEntityPerson p in persons)
                Console.WriteLine("{0} in {1}", p.Name, p.City);
        }
    }
}
